home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / lollipop / opt.tex < prev    next >
Text File  |  1993-01-28  |  14KB  |  393 lines

  1. % Opt.tex copyright 1992 Victor Eijkhout
  2. %
  3. \Chapter Options
  4.  
  5. This chapter discusses the various options that are common to all
  6. \Lollipop\ constructs.
  7.  
  8. \Section Titles
  9.  
  10. Any construct can have a title, although of course it is most useful
  11. for headings. 
  12. A construct has a title if the option \refopt{title} appears. 
  13. Example:
  14. \Ver>
  15. \DefineHeading:Section [...]
  16.     Style:bold title
  17.     [...] Stop<Rev
  18.  
  19. will define a \cs{Section} macro that has a title. 
  20. The macro is then used as
  21. \Ver>
  22. \Section The title of this section
  23.  
  24. Some text in this section.<Rev
  25. that is, the title is delimited by an empty line.
  26.  
  27. The title is actually available as a macro \refcs{FooTitle}, so that you
  28. can write a macro, for instance
  29. \Ver>
  30. \def\ComplicatedTitle{ .. \hrule ... 
  31.     \vrule ... \vbox \bgroup ...
  32.     \FooTitle ...
  33.     }<Rev
  34. and use this macro instead of the \opt{title} option
  35. \Ver>\DefineBar:Foo ...
  36.     ComplicatedTitle
  37.     ... Stop<Rev
  38. However, since the option \opt{title} now doesn't appear anymore, it
  39. becomes necessary to specify explicitly that there is a title.
  40. This can be done with the \refopt{HasTitle} option. For instance,
  41. you define
  42. \Ver>\DefineBar:Foo ...
  43.     HasTitle
  44.     ComplicatedTitle
  45.     ... Stop<Rev
  46. where \cs{ComplicatedTitle} is a macro that formats the title.
  47.  
  48. \SubSection Short titles
  49.  
  50. The option \opt{HasTitle} can have a parameter \n{short}, denoting that
  51. the title is not delimited by an empty line (or \cs{par}) but by the
  52. line end. For an example see section~\ref[sec:address].
  53.  
  54. \Section[sec:opt:counter] Counters
  55.  
  56. There are three ways for Lollipop to figure out that a generic
  57. construct has a counter. First of all, in
  58. \Ver>\DefineFoo:Bar [...]
  59.     BarCounter [...]<Rev
  60. the \cs{BarCounter} will be defined automatically.
  61.  
  62. Additionally there is the option \refopt{counter}, which can be used
  63. to declare the representation of the option, for instance
  64. \opt{counter:i} allocated a counter that is printed in lowercase roman
  65. numerals. For the available representations,
  66. see~\ref[sec:counter:repr].
  67.  
  68. Finally, if the counter is only used in a macro, the
  69. option \refopt{HasCounter} will cause the counter to be created anyhow.
  70. This is analogous to the \opt{HasTitle} option.
  71.  
  72. \SubSection Counter synonyms
  73.  
  74. Every once in a while you may want different constructs to use the same
  75. counter. For instance, if your book has definitions, theorems, lemmas,
  76. corollaries and notations, it may confuse the reader if they all have
  77. their own counter. The numbering would seem to jump all over the place.
  78.  
  79. A `counter synonym' can be declared in \Lollipop\ by a slight abuse of
  80. the \opt{counter} option.
  81. \Example
  82. \DefineTextBlock:Theorem counter:1 begingroup Style:bold
  83.  literal:Theorem Spaces:1 TheoremCounter Spaces:2 endgroup
  84.  text Stop
  85. \DefineTextBlock:Corollary counter:Theorem begingroup Style:italic
  86.  literal:Corollary Spaces:1 CorollaryCounter Spaces:2 endgroup
  87.  text Stop
  88. \DefineTextBlock:Definition counter:Theorem begingroup Style:roman
  89.  literal:Definition Spaces:1 DefinitionCounter Spaces:2 endgroup
  90.  text Stop
  91. \Definition We define a {\it Foo} to be an arbitrary object\>
  92. \Theorem Foos have arbitrary properties\>
  93. \Corollary Foos are extremely valuable\>
  94. \Corollary Foos are extremely worthless\>
  95. \Theorem Foos don't exist\>
  96. \ExampleStop
  97.  
  98. You can only declare a counter to be synonym for something that has
  99. already been created. In the above example you cannot define the
  100. \cs{Theorem} after the \cs{Corollary}.
  101.  
  102. \ImpNote
  103. At the start of defining the construct, \cs{BarCounter} is defined to
  104. be an option:
  105. \Ver>\add@generic@default{\has@counterno
  106.     \def\counter@repr{1}
  107.     \csarg\def{\gen@option@name{\@name Counter}}{%
  108.         \@add@toks{\@name Counter}\global\has@counteryes}}<Rev
  109.  
  110. Then,
  111. \Ver>\add@generic@stop@default{\ifhas@counter
  112.     \xp\expandafter\xp\install@counter
  113.            \xp\counter@repr\@space\fi}<Rev
  114.  
  115.  
  116. The counter is stepped, and the new value is stored in a mark item,
  117. in \cs{outer@start@commands}:
  118.  
  119. \Ver>
  120.     \ifhas@counter 
  121.        \nxp\StepCounter:\expandafter\@name\@space
  122.        % This sets the \current@label by default
  123.        \ifhas@marks \edef\nxp\cs@e
  124.               {\nxp\nxp\nxp\refresh@mark@item
  125.                 {\@name Counter}{\CSname{\@name Counter}}}%
  126.             \nxp\cs@e      
  127.        \fi
  128.        \fi<Rev
  129. \ImpNoteStop
  130.  
  131. \Section Chunks of text
  132.  
  133. Especially in headings, short chunks of text may need a special
  134. treatment. For instance, the number may have to be filled to a certain
  135. width, or a line may have to be drawn of the exact length of the
  136. title. Lollipop have various general options (so they can also be used
  137. in other contexts than headings) for handling pieces of text.
  138.  
  139. \SubSection[sec:opt:block] The \opt{block} option\label[opt:block]
  140.  
  141. The \refopt{block} option takes up a piece of text and fits it on one
  142. line. It can measure the text, or set the size. Also there are a number
  143. of ways of placing a block.
  144.  
  145. Basic usage:
  146. \Ver>    block:start [...] block:stop<Rev
  147. This takes the enclosed text, and reproduces it. This is mostly
  148. interesting in combination with \opt{textcolumn},
  149. see~\ref[sec:opt:textcolumn].
  150. \Ver>    block:hang [...] block:stop<Rev
  151. The resulting block is dropped until its top touches the baseline.
  152. For uniformity of appearance, the resulting width of the block can be
  153. specified:
  154. \Ver>    block:start [...] fillupto:20pt<Rev
  155. The name of a \cs{Distance} parameter can be used here.
  156.  
  157. \Example
  158. \DefineHeading:TestHeading
  159.  line:start block:hang PointSize:8 SetFont 
  160.                   TestHeadingCounter fillupto:20pt
  161.             block:hang PointSize:14 SetFont title block:stop
  162.  line:stop Stop
  163. \TestHeading Top Aligning the Title
  164.  
  165. \endExample
  166.  
  167. The block is usually in between the margins of the text, but it can be
  168. made to stick out into the margin, by closing it with the option
  169. \refopt{stickout}.  For the left margin this done as
  170.  \Ver>    block:start [...] stickout:left<Rev
  171. and for the right margin
  172.  \Ver>    block:start [...] stickout:right<Rev
  173. The size of the box can be specified, for instance as
  174.  \Ver>    block:start [...] stickout:left=20pt<Rev
  175. For a left box the material in it is pushed to the left edge, for a
  176. right sticking box it is shifted to the right.
  177.  
  178. \SubSection[sec:blockwidth] Block Measuring
  179.  
  180. All blocks are immediately measured when they are placed. This makes it
  181. possible for instance to underline a title exactly. After a block has
  182. been placed, its width is available as \refcs{BlockWidth}.
  183.  \Example
  184. \def\rulespecs{height 1pt width \BlockWidth\relax}
  185. \DefineHeading:TestHeading Style:bold
  186.  line:start block:start TestHeadingCounter . Spaces:2 stickout:left
  187.             block:start title block:stop line:stop
  188.  vwhite:2pt hrule rulespecs vwhite:10pt Stop
  189. \TestHeading The Title Is Underlined
  190.  
  191. The text follows.
  192. \ExampleStop
  193. Observe how a control sequence \cs{rulespecs} is used to sneak the
  194. height and width of the rule into the definition. This is necessary
  195. because control sequences are not allowed in a construct definition.
  196.  
  197. \SubSection[sec:opt:line] The \opt{line} option
  198.  
  199. The option \refopt{line} is used to create a single strip of text that
  200. fits exactly in between the margins of the page. Most of the time, titles
  201. will be in a line. 
  202.  
  203. \Example
  204. \DefineHeading:TestHeading
  205.     line:start block:start TestHeadingCounter Spaces:1.5 stickout:left
  206.                title line:stop Stop
  207. \TestHeading A Title
  208.  
  209. \endExample
  210.  
  211. Another example was above. Here is another use of a line:
  212.  
  213. \Example
  214. \DefineHeading:TestHeading
  215.     line:start TestHeadingCounter fillup title line:stop Stop
  216. \TestHeading The title
  217.  
  218. \endExample
  219.  
  220. \SubSection[sec:opt:textcolumn] The \opt{textcolumn} option
  221.  
  222. In the examples above all titles fit on one line comfortably. If this
  223. is not the case, the title can be put in a \refopt{textcolumn} which can
  224. span several lines.
  225.  
  226. \Example
  227. \DefineHeading:TestHeading
  228.     line:start block:start TestHeadingCounter Spaces:2 block:stop
  229.                textcolumn:topline title textcolumn:stop
  230.     line:stop Stop
  231. \TestHeading A very very very very very very very very very very very
  232. very very very very very very very very very very very very very
  233. very very very very very very very very long title
  234.  
  235. \endExample
  236.  
  237. This option is mostly interesting in combination with others such as
  238. \opt{block} and \opt{line}. As is apparent from the above example: a
  239. block placed in the same line as a text column will detract from the
  240. latter's width. 
  241.  
  242. (In fact it is the other way around: \Lollipop\ sets
  243. the line with a text column of width zero to determine the remaining
  244. space. Then the line is set again. This may give problems if you
  245. manipulate parameters inside the line, because the line is in effect
  246. typeset twice. Also make sure not to have other \cs{vbox}-es in the
  247. line than the text column.)
  248.  
  249. \SubSection[sec:opt:traps] Traps
  250.  
  251. It is a bad idea to have material in headings and such that is not
  252. inside a block, textcolumn, or line. For instance:
  253.  
  254. \Example
  255. \DefineHeading:TestHeading
  256.     block:start TestHeadingCounter Spaces:2 block:stop
  257.     title Stop
  258. \TestHeading Where does the title go?
  259.  
  260. \endExample
  261.  
  262. \Section[sec:opt:label] Labels
  263.  
  264. References to any counter will always be correct, no matter if that
  265. counter has changed after retypesetting the document, if symbolic
  266. references are used. Referencing is explained in detail in
  267. chapter~\ref[chap:referencing].
  268.  
  269. The way a symbolic reference is formatted can be altered from the
  270. default (just give the counter) by using the \refopt{label} option.
  271. \Ver>\DefineHeading:TestSection
  272.  line:start Style:italic TestSectionCounter Spaces:2 title line:stop
  273.  label:start ( TestSectionCounter ) label:stop Stop<Rev
  274. See further section~\ref[sec:shape:reference].
  275.  
  276.  
  277. \Section[sec:opt:penalties] Break before / after
  278.  
  279. The options \refopt{breakbefore} and \refopt{breakafter} control how
  280. eager \TeX\ will be to break the page before or after a construct. These
  281. options take one value, a so-called `penalty' value, meaning that the
  282. higher the value you specify, the higher the penalty is, and
  283. therefore the less likely it is that the page will be broken there.
  284.  
  285. Numerical values are typically in the tens or hundreds; any value
  286. of \n{10$\,$000} or more means that there will never be a break at
  287. that point; a value of \n{-10$\,$000} or less means a guaranteed
  288. break. If you don't want to remember these rules, values of \n{yes}
  289. and \n{no} mean a guaranteed break, and no break respectively.
  290.  
  291. \WizNote
  292. A further exceptional value is \n{breakbefore/after:0}, this will
  293. cause no penalty to be placed. The reason for this is highly \TeX
  294. nical.
  295. \>
  296.  
  297. \Section[sec:opt:indent] Indentation
  298.  
  299. The option \refopt{indentafter} controls the behaviour of the first
  300. paragraph after a generic construct., \refopt{indentinside},
  301. \refopt{indentfirst}.
  302.  
  303. \Section Rules
  304.  
  305. There is an option \refopt{hrule}. You should not write
  306. \Ver>\def\rulemacro{\hrule height [...] }
  307. \DefineHeading [...] rulemacro [...] Stop<Rev
  308. because then \Lollipop\ cannot prevent page breaks around the rule.
  309. Instead write 
  310. \Ver>\def\rulespecs{ height [...] }
  311. \DefineHeading [...] hrule rulespecs [...] Stop<Rev
  312. so that the option \opt{hrule} is used. See
  313. section~\ref[sec:blockwidth] for an example.
  314.  
  315. \Section Embedded constructs
  316.  
  317. Most generic constructs will be vertically separated from the
  318. surrounding text. However, in rare cases (and for unusual applications)
  319. it be desired to have a construct that is part of a paragraph. For this
  320. the option \refopt{embedded} exists.
  321.  
  322. This option has the following values.
  323. \Ver>    embedded:no<Rev
  324. This is the default.
  325. \Ver>    embedded:left<Rev
  326. The construct continues an already started paragraph, but after the
  327. construct a vertical break follows.
  328. \Ver>    embedded:right<Rev
  329. After the construct a paragraph can continue, but the construct is
  330. separated vertically from preceding text.
  331. \Ver>    embedded:yes<Rev
  332. The construct is both left and right embedded.
  333.  
  334. Embedding a construct has an interesting application to generating
  335. indexes. (See chapter~\ref[chap:external-files] for general information
  336. about external files.) This can be done by having embedded headings
  337. that write their title to the index file.
  338.  
  339. \Example
  340. \DefineExternalFile:tIndex=tix
  341. \DefineHeading:NewWord embedded:yes 
  342.  block:start Style:bold title block:stop
  343.  external:tIndex title external:stop Stop
  344. \def\introword#1{\NewWord #1\par}
  345. In this sentence two \introword{flubrious} words are
  346. \introword{stinselsed}.
  347. \ExampleStop
  348.  
  349. Cute, ain't it?
  350.  
  351. A word of warning though. Headings and such generate \TeX\ `marks'
  352. which take up main memory. You only need these if you are going
  353. to be referring to that object with \cs{LastPlaced} or such; see
  354. section~\ref[sec:head/foot]. Embedded headings used as above
  355. usually don't need these marks, so you can prevent \TeX\ overflow by
  356. putting the option \opt{nomarks} in their definition.
  357.  
  358. \Section Obscure options
  359.  
  360. \SubSection Arguments
  361.  
  362. In case you want to interface to other macro packages, you may want to
  363. let a construct generate a call to the other package. For this, the
  364. \Lollipop\ macro should be able to produce sequences such as
  365. \ver>\begin{itemize}>. The problem here is the braces. The option
  366. \refcs{arg} produces a braced expression.
  367.  
  368. For instance
  369. \Ver>\DefineTextBlock:LaTeXlist begin arg:{itemize} text
  370.     end arg:{itemize} Stop<Rev
  371. makes it possible to use call \LaTeX\ macros from \Lollipop.
  372.  
  373. \SubSection[sec:implicit:close] Implicit closing
  374.  
  375. The control sequence \refcs{>} closes the current group, and \refcs{>]}
  376. closes all currently open groups. Every once in a while this is too
  377. drastic. Hence there is an option \refopt{noimplicitclose} that can be
  378. used to prevent a construct from being closed implicitly. Using \cs{>]}
  379. inside such a construct will close all enclosed constructs.
  380.  
  381. See the definition of \cs{EExample} in this manual for an example.
  382.  
  383. \Section[sec:opt:test] Testing
  384.  
  385. There is an option \opt{test}.
  386.  
  387. \endinput
  388.  
  389. 92/11/10 \BlockWidth discussed in 'block' section
  390. 92/11/15 counter:othercounter discussed
  391. 92/11/21 option 'arg'
  392.  
  393.